Skip to content

Scoring chain#15

Merged
ma2bd merged 6 commits intolinera-io:mainfrom
ma2bd:backend
Sep 14, 2025
Merged

Scoring chain#15
ma2bd merged 6 commits intolinera-io:mainfrom
ma2bd:backend

Conversation

@ma2bd
Copy link
Contributor

@ma2bd ma2bd commented Sep 13, 2025

  • User chains now message the "scoring chain" whenever they solve a puzzle.
  • The scoring chain keeps track of registered puzzles (to avoid spam).
  • User chains don't (we use code generation instead)
  • When a message is received, we add the puzzle to the list of solved puzzles for this owner.
  • Users (later AI agents) can contribute solutions in the name of someone else.

Note:

  • We don't use message grants. Maybe that's ok for now because it's easy to give lots of testnet tokens to this particular appchain.
  • I can try to add unit tests with claude later today
flowchart LR
    user1("web user")
    user2("admin user") --> admin("admin CLI wallet")
    service("GoL service (private GraphQL API)")
    external("external service")
    user2 -- Registers puzzles --> service
    style user1 fill:#f9f,stroke:#333,stroke-width:1px,color:#000
    style user2 fill:#f9f,stroke:#333,stroke-width:1px,color:#000
    style external fill:#aff,stroke:#333,stroke-width:1px,color:#000

    subgraph "Linera network"
        chain1["user chain"]
        chain2["user chain"]
        chain3["GoL scoring chain"]
        style chain1 fill:#bbf,stroke:#333,stroke-width:1px,color:#000
        style chain2 fill:#bbf,stroke:#333,stroke-width:1px,color:#000
    end

    user1 -- submits solution --> chain1
    chain2 -- creates chain --> chain3
 	  chain1 -- notifies solution --> chain3

	  admin -- publishes puzzle as blob --> chain2
	  admin -- creates GoL scoring chain --> chain2
 	  admin -- creates GoL application --> chain2
 	  service -- processes inbox --> chain3
 	  service -- registers puzzle --> chain3
 	  external -- replicates scores --> chain3
 	  portal("portal backend") -- queries --> external
Loading

@ma2bd ma2bd requested a review from deuszx September 14, 2025 06:07
@ma2bd ma2bd marked this pull request as ready for review September 14, 2025 06:07
@ma2bd ma2bd requested a review from Twey September 14, 2025 06:07
@ma2bd ma2bd requested a review from TudorEsan September 14, 2025 06:26
Copy link
Contributor

@deuszx deuszx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. As someone who wrote contracts on many different chains, I find it bit weird that contract that verifies the puzzles and contract that submits them is the same one but I understand that it's necessary for the cross-chain messages to work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of introducing more branching in the contract, might be easier to just make it a required field and set the authenticated owner when constructing the operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No actually, web frontends don't want to figure out who the owner is. This will be used by AI agents.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nothing to figure out – web frontend is connected to a wallet (signer) with that information. It needs to sign the block proposal (mutation) anyway.

Copy link
Contributor Author

@ma2bd ma2bd Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frontends don't sign anything but perhaps you just mean that they could easily ask the wallet who's the current user, which I agree.

Comment on lines 134 to 152
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

being able to query on-chain data like this is really a game-changer.

Do we support limits and offsets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we support standard GraphQL-like pagination yet but it could be added in linera-views.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For airdrops and ERC20-like tokens, with possibly thousands of holders, this will be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if we're going to read the whole state.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(not from this PR but): I'd expect this API to be the other way around– puzzle.check_solution(&board). A board is a solution to a specific puzzle (a puzzle can have many different solutions/boards but a board can be a solution to one puzzle).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. Let me look

@ma2bd
Copy link
Contributor Author

ma2bd commented Sep 14, 2025

Looks great. As someone who wrote contracts on many different chains, I find it bit weird that contract that verifies the puzzles and contract that submits them is the same one but I understand that it's necessary for the cross-chain messages to work.

Interesting. They could be different in this case. What we don't (easily) support (yet) is mutually recursive applications.

@deuszx
Copy link
Contributor

deuszx commented Sep 14, 2025

Looks great. As someone who wrote contracts on many different chains, I find it bit weird that contract that verifies the puzzles and contract that submits them is the same one but I understand that it's necessary for the cross-chain messages to work.

Interesting. They could be different in this case. What we don't (easily) support (yet) is mutually recursive applications.

To me, the "Solution chain/app" is like a registry:

  • keeps track of puzzles
  • users' scores

The other part are user chains where those puzzles are verified. Here every contract can act as both.

I don't think that's a big issue but I think that in terms of seperation of concerns/responsibilities that's where I'd draw the line.

@ma2bd ma2bd merged commit 6addd0e into linera-io:main Sep 14, 2025
2 checks passed
@ma2bd ma2bd deleted the backend branch September 14, 2025 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants